package com.ldy.core.util;

import java.util.HashMap;
import java.util.Map;

import org.apache.http.HttpHost;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ReqUtil {

	public static final Logger logger = LoggerFactory.getLogger(ReqUtil.class);
	
	private Map<String, String> appData = new HashMap<String, String>();
	
	// 当前 cookies
	private Map<String, String> currentCookies = new HashMap<String, String>();

	public String username;

	public String password;

	public HttpHost proxy;

	public ReqUtil(String username, String password, HttpHost proxy) {
		this.username = username;
		this.password = password;
		this.proxy = proxy;
		appData = new HashMap<String, String>();
	}

	

	
	public void put(String key,String value) {
		appData.put(key, value);
	}
	public String get(String key) {
		return appData.get(key);
	}
	

	
	public void setCookies(Map<String, String> cookies) {
		for (String key : cookies.keySet()) {
			currentCookies.put(key, cookies.get(key));
		}
	}

	public String getCookies() {
		StringBuffer sb = new StringBuffer();
		for (String key : currentCookies.keySet()) {
			sb.append(key).append("=").append(currentCookies.get(key)).append(";");
		}
		return sb.toString();
	}

}
